home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1993 September / clonecd / September 93.img / Archives / Applications / Calculators / AxoCalculator / AxoCalculator AutoLoad / dec2hex next >
Text File  |  1993-01-24  |  774b  |  34 lines

  1. Procedure dec2hex(dec: Integer)
  2. VAR
  3.     i,j,k,hex:        Integer
  4.     leftZeros:        Boolean
  5. begin
  6.     leftZeros = true
  7.     for i = 1 to 8 do
  8.     begin
  9.         j = 16 ^ (8 - i)
  10.         hex = dec DIV j
  11.         if hex <> 0 then leftZeros = false
  12.         if not leftZeros then
  13.         begin
  14.             dec = dec - hex * j
  15.             if hex = 0 then write ('0')
  16.             if hex = 1 then write ('1')
  17.             if hex = 2 then write ('2')
  18.             if hex = 3 then write ('3')
  19.             if hex = 4 then write ('4')
  20.             if hex = 5 then write ('5')
  21.             if hex = 6 then write ('6')
  22.             if hex = 7 then write ('7')
  23.             if hex = 8 then write ('8')
  24.             if hex = 9 then write ('9')
  25.             if hex = 10 then write ('A')
  26.             if hex = 11 then write ('B')
  27.             if hex = 12 then write ('C')
  28.             if hex = 13 then write ('D')
  29.             if hex = 14 then write ('E')
  30.             if hex = 15 then write ('F')
  31.         end
  32.     end
  33. end
  34.